//
//  NSObject+HQObserverHelper.h
//  MengLiao
//
//  Created by xiuxin on 2022/7/15.
//  Copyright © 2022 ZHBen. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface NSObject (KObserverHelper)

/**
 safe-kvo

 @param observer 观察者
 @param keyPath 被观察的对象
 @param options 观察策略
 @param context null
 */
- (void)k_addObserver:(nonnull NSObject *)observer forKeyPath:(nonnull NSString *)keyPath options:(NSKeyValueObservingOptions)options context:(nullable void *)context;

/**
 移除观察

 @param observer 观察者
 @param keyPath 被观察的对象
 @param context null
 */
- (void)k_removeObserver:(nonnull NSObject *)observer forKeyPath:(nonnull NSString *)keyPath context:(nullable void *)context;

/**
 判断是否被observer观察keyPath
 */
- (BOOL)k_isObservedBy:(NSObject *)observer keyPath:(NSString *)keyPath;

@end

NS_ASSUME_NONNULL_END
